function fdata = fkfilter(data, trhdr, dt, vmin)

[~, idx] = sort([trhdr.offset], 'ascend');
data = data(:, idx);
trh = trhdr(idx);
% [nt, ntr] = size(data);
dx = unique(diff([trh.offset]));
td = fft(data);
[m, n] = size(td);
spec_t = td(1:floor(m/2)+1, :);
spec = fft(spec_t')';
f = (0:floor(m/2))/m/dt;
kx = (0:n-1)/n/dx;
for i = 1:length(kx)
    if kx(i) >= 1/2/dx
        kx(i) = kx(i) - 1/dx;
    end
end
[kx, sidx] = sort(kx);
spec = spec(:, sidx);
% figure;
% imagesc([min(kx), max(kx)], [min(f), max(f)], abs(spec));
mask = zeros(size(spec));
for i = 1:size(spec, 1)
    for j = 1:size(spec, 2)
        v = abs(f(i)/kx(j));
        if v > vmin
            mask(i, j) = 1;
        end
    end
end
mspec = mask.*spec;
% figure; imagesc([min(kx), max(kx)], [min(f), max(f)], abs(mspec));hold on;
% imagesc(mask, 'AlphaData', 0.5);
[~, tindex] = sort(sidx);
m_spec_t = ifft(mspec(:, tindex)')';
fdata = real(ifft([m_spec_t; conj(m_spec_t(end:-1:2, :))]));
[~, ridx] = sort(idx);
fdata = fdata(:, ridx);
end